package com.pwc.workQueue;

import com.pwc.utils.RabbitUtil;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

public class ConsumerMessageLost2 {
    private final static String QUEUE_NAME = "aaa";

    public static void main(String[] args) throws IOException, TimeoutException {
        Channel channel = RabbitUtil.createChannel();
        //不公平分发
        channel.basicQos(7);
        System.out.println("c2 ===slow====");
        DeliverCallback deliverCallback = (consumerTag, message) -> {
            try {
                Thread.sleep(10000);
                System.out.println("接收到的信息" + new String(message.getBody(), "utf-8"));
                channel.basicAck(message.getEnvelope().getDeliveryTag(), false);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        };

        channel.basicConsume(QUEUE_NAME, false, deliverCallback, (consumerTag) -> {
        });

    }
}
